package com.homedo.microservice.open.service.gateway.manager.web.remote.api.impl;

import com.homedo.common.bean.data.ResponseData;
import com.homedo.common.bean.vo.context.UserContext;
import com.homedo.common.bean.vo.context.UserVo;
import com.homedo.microservice.open.service.gateway.manager.web.api.ILoginServiceRemote;
import com.homedo.microservice.open.service.gateway.manager.web.api.bean.model.resp.UserAResp;
import com.homedo.microservice.open.service.gateway.manager.web.util.UserContextUtil;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginServiceRemote implements ILoginServiceRemote {

    @Override
    public ResponseData<UserAResp> getUserInfo() {
        ResponseData<UserAResp> responseData = new ResponseData<>();

        UserContext userContext = UserContextUtil.getUserContext();
        UserVo userVo = userContext.getUser();

        UserAResp userAResp = new UserAResp();
        userAResp.setUsername(userVo.getAccountName());
        userAResp.setRealname(userVo.getAccountRealName());
        userAResp.setId((int) userVo.getAccountId());

        responseData.setData(userAResp);

        return responseData;
    }
}
